package name.marz.to.go.ahg.nifty;

import java.net.URI;
import java.util.List;

import name.marz.to.go.ahg.common.util.HttpUtil;
import name.marz.to.go.ahg.core.AutoGetterHttpClient;
import name.marz.to.go.ahg.core.Parameters;
import name.marz.to.go.ahg.core.checker.DocumentChecker;
import name.marz.to.go.ahg.core.exception.UserProcessException;
import name.marz.to.go.ahg.core.executer.AbstractLoginExecuter;

import org.apache.http.NameValuePair;
import org.jsoup.nodes.Document;

public class NiftyLoginExecuter extends AbstractLoginExecuter {
	/**
	 * 
	 */
	private static final String FORM_NAME = "login";
	private Document doc;
	
	/**
	 * ログインチェッカーの実装
	 */
	private DocumentChecker checker = new DocumentChecker() {
		@Override
		public void check(Document doc) throws UserProcessException {
			// TODO Auto-generated method stub
			
		}
	};

	public NiftyLoginExecuter(URI uri, AutoGetterHttpClient client, String[] userIds,
			String pass, Document doc) {
		super(uri, client, userIds, pass);
		this.doc = doc;
	}

	@Override
	protected List<NameValuePair> getRequestParameters() {
		Parameters p = HttpUtil.getParametersFromFormTag(doc,FORM_NAME);
		p.put("username", super.userIdentifiers[0]);
		p.put("password", super.userPass);
		return p.getNameValueList();
	}

	@Override
	protected DocumentChecker getChecker() {
		return checker;
	}
}